<!-- 理化检测任务单详情(委托型) -->
<template>
    <div class="dialog-container" id="dialog-container">
        <el-dialog v-dialogDrag :fullscreen="isFullScreen" :custom-class="isFullScreen?'fullscreen-default-dialog':'vertical-center-dialog'" append-to-body :close-on-click-modal="false" :visible.sync="dialogVisible" @close="$emit('update:show', false)" :before-close="handleClose" :show="show" width="800px">
            <div slot="title">
                <span style="color:white;">数据上传</span>
                <button type="button" aria-label="fullScreen" class="el-dialog__headerbtn" style="margin-right:25px;" @click="isFullScreen = !isFullScreen">
                    <i class="el-dialog__close iconfont icon-fuzhicopy22"></i>
                </button>
            </div>
            <div class="uploadTitle">
                <img src="../../../../../assets/images/sagw.png" style="float:left;">
                <h2 style="text-align:center;">理化检测报告</h2>
                <span style="float: right;">委托单号：{{form.taskNo}}</span>
            </div>
            <el-form :model="form" :inline="true" label-width="130px" size="small">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="零件号：">
                            <el-input v-model="form.partNumber" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="热处理炉号：">
                            <el-input v-model="form.heatingNumber" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="任务类型：" prop="taskType">
                          <!--<el-input v-model="form.taskType" disabled></el-input>-->
                         {{getType(form.taskType)}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="零件名称：">
                            <el-input v-model="form.partName" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="批次零件总数量：">
                            <el-input v-model="form.totalPartNo" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="委托方：">
                            <el-input v-model="form.applyUser.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="零件图号：">
                            <el-input v-model="form.partGraphNumber" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="材料牌号：">
                            <el-input v-model="form.materialNo" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="委托日期：">
                            <el-date-picker v-model="form.applyTime" type="date" disabled style="width: 200px;"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="图纸版本：">
                            <el-input v-model='form.part.partGraphNumber' disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="材料炉号：">
                            <el-input v-model="form.materialFurnanceNumber" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <!--<el-col :span="12">
            <el-form-item label="委托单号：">
              <el-input v-model='form.taskNo' disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>-->

                    <el-col :span="12" v-if="form.taskType==1">
                        <el-form-item label="需求完成日期：">
                            <el-input v-model="form.expectCompleteTime" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="样品信息："> {{this.sampleStatusName}}共 {{form.quantity}} 件
                            <!-- <el-radio-group v-model="form.sampleStatus" disabled>
                                <el-radio label="实物">{{form.sampleStatus}}
                                    <el-input v-if="form.sampleStatus == '实物'" v-model="form.quantity" disabled style="width: 70px;margin: 0 5px;"></el-input>件</el-radio>
                                <el-radio label="试样">试样
                                    <el-input v-if="form.sampleStatus == '试样'" v-model="form.quantity" disabled style="width: 70px;margin: 0 5px;"></el-input>件</el-radio>
                            </el-radio-group> -->
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="备注：">
                            <el-input type="textarea" v-model="form.remark" disabled style="width: 580px;"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="form.taskType==1">
                    <el-col :span="24">
                        <el-form-item label="任务目的与要求：">
                            <el-radio-group disabled v-model="form.taskTarget">
                                <el-radio label="新产品试制">新产品试制</el-radio>
                                <el-radio label="常规均匀性实验">常规均匀性实验</el-radio>
                                <el-radio label="失效零件分析">失效零件分析</el-radio><br>
                                <el-radio label="复检">复检</el-radio>
                                <el-radio label="设备新增/大修验收">设备新增/大修验收</el-radio>
                                <el-radio label="其他">其他</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-tabs v-model="activeName" @tab-click="handleClick">
                    <el-tab-pane :label="item.title" :name="item.title" v-for="item in editableTabs" :key="item.key">
                        <el-table :data="tableData[item.key]">
                            <el-table-column type='index' label="编号" align="center" width="60"></el-table-column>
                            <el-table-column prop="taskField.fieldName" label="检测项目" align="center" width="100">
                                <template slot-scope="scope">
                                    <!-- <span v-if='rowResult(scope.row)==0' style='color:red'>{{scope.row.taskField.fieldName}}</span> -->
                                    <span>{{scope.row.taskField.fieldName}}</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="testPart" label="检测位置" align="center" width="100">
                                <template slot-scope="scope">
                                    <!-- <span v-if='rowResult(scope.row)==0' style='color:red'> {{getPosition(scope.row.taskField.testPart)}}</span> -->
                                    <span> {{getPosition(scope.row.taskField.testPart)}}</span>
                                </template>
                            </el-table-column>

                            <el-table-column prop="standardInfoStr" label="检测要求" align="center" width="180">

                            </el-table-column>
                           <!--  <el-table-column prop="taskField.partField.unit" label="单位" align="center" width="150">

                            </el-table-column>
                           <el-table-column prop="taskField.standardInfo" label="检测标准" align="center" width="150">
                                <template slot-scope="scope">
                                    <span v-if='rowResult(scope.row)==0' style='color:red'>{{scope.row.taskField.standardInfo}}</span>
                                    <span v-else>{{scope.row.taskField.standardInfo}}</span>
                                </template>
                            </el-table-column>-->
                            <el-table-column label="实测数据">
                                <el-table-column prop="actData1" label="1" align="center" width="100">
                                    <template slot-scope="scope">

                                        <el-radio-group v-model="scope.row.actData1" :class="unqualifiedColColor(scope.row, 1)==0 ? 'font-color-red': 'font-color-normal'" :disabled='getStatus(scope.row,1)' @change='changeData(scope.row,1)' v-if='scope.row.taskField.partField.operator=="choose"'>
                                            <el-radio label="1">符合</el-radio>
                                            <el-radio label="0">不符合</el-radio>
                                        </el-radio-group>
                                        <el-input v-model='scope.row.actData1' :class="unqualifiedColColor(scope.row, 1)==0 ? 'font-color-red': 'font-color-normal'" @change='changeData(scope.row,1)' :disabled='getStatus(scope.row,1)' v-else>
                                        </el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="actData2" label="2" align="center" width="100">
                                    <template slot-scope="scope">

                                        <el-radio-group v-model="scope.row.actData2" :class="unqualifiedColColor(scope.row, 2)==0 ? 'font-color-red': 'font-color-normal'" @change='changeData(scope.row,2)' :disabled='getStatus(scope.row,2)' v-if='scope.row.taskField.partField.operator=="choose"'>
                                            <el-radio label="1">符合</el-radio>
                                            <el-radio label="0">不符合</el-radio>
                                        </el-radio-group>
                                        <el-input v-model='scope.row.actData2' :class="unqualifiedColColor(scope.row,2)==0 ? 'font-color-red': 'font-color-normal'" @change='changeData(scope.row,2)' :disabled='getStatus(scope.row,2)' v-else>
                                        </el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="actData3" label="3" align="center" width="100">
                                    <template slot-scope="scope">


                                        <el-radio-group v-model="scope.row.actData3" :class="unqualifiedColColor(scope.row, 3)==0 ? 'font-color-red': 'font-color-normal'" @change='changeData(scope.row,3)' :disabled='getStatus(scope.row,3)' v-if='scope.row.taskField.partField.operator=="choose"'>
                                            <el-radio label="1">符合</el-radio>
                                            <el-radio label="0">不符合</el-radio>
                                        </el-radio-group>
                                        <el-input v-model='scope.row.actData3' :class="unqualifiedColColor(scope.row, 3)==0 ? 'font-color-red': 'font-color-normal'" @change='changeData(scope.row,3)' :disabled='getStatus(scope.row,3)' v-else>
                                        </el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="actData4" label="4" align="center" width="100">
                                    <template slot-scope="scope">


                                        <el-radio-group v-model="scope.row.actData4" :class="unqualifiedColColor(scope.row, 4)==0 ? 'font-color-red': 'font-color-normal'" @change='changeData(scope.row,4)' :disabled='getStatus(scope.row,4)' v-if='scope.row.taskField.partField.operator=="choose"'>
                                            <el-radio label="1">符合</el-radio>
                                            <el-radio label="0">不符合</el-radio>
                                        </el-radio-group>
                                        <el-input v-model='scope.row.actData4' :class="unqualifiedColColor(scope.row, 4)==0 ? 'font-color-red': 'font-color-normal'" @change='changeData(scope.row,4)' :disabled='getStatus(scope.row,4)' v-else>
                                        </el-input>


                                    </template>
                                </el-table-column>
                                <el-table-column prop="actData5" label="5" align="center" width="100">
                                    <template slot-scope="scope">

                                        <el-radio-group v-model="scope.row.actData5" :class="unqualifiedColColor(scope.row, 5)==0 ? 'font-color-red': 'font-color-normal'" @change='changeData(scope.row,2)' :disabled='getStatus(scope.row,5)' v-if='scope.row.taskField.partField.operator=="choose"'>
                                            <el-radio label="1">符合</el-radio>
                                            <el-radio label="0">不符合</el-radio>
                                        </el-radio-group>
                                        <el-input v-model='scope.row.actData5' :class="unqualifiedColColor(scope.row, 5)==0 ? 'font-color-red': 'font-color-normal'" @change='changeData(scope.row,5)' :disabled='getStatus(scope.row,5)' v-else>
                                        </el-input>
                                    </template>
                                </el-table-column>
                            </el-table-column>
                            <el-table-column prop="device" label="检测设备" align="center" width="150">
                                <template slot-scope="scope">
                                    <el-select v-model='scope.row.deviceId'>
                                        <el-option v-for="item in scope.row.taskField.deviceList" :key="item.id" :label="item.codeAndName" :value="item.id"></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column prop="remark" label="备注" align="center" width="200">
                                <template slot-scope="scope">
                                    <el-input v-model='scope.row.remark'>
                                    </el-input>
                                </template>
                            </el-table-column>
                            <el-table-column prop="remark" label="附件" align="center" width="200">
                                <template slot-scope="scope">
                                    <a href="javascript:void(0)" @click='downloadResultAttach(scope.row.id)'>{{scope.row.fileName}}</a>
                                    <el-upload class="upload-demo" :on-success="successResultUpload" :action="uploadResultUrl" :data="{resultId:scope.row.id}">
                                        <el-button size="small" type="primary">上传附件</el-button>
                                    </el-upload>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-tab-pane>

                </el-tabs>



                <el-row style="margin-top: 10px;">
                    <el-col :span="16">
                        <el-form-item label="上传附件：">
                            <el-upload class="upload-demo" ref="upload" :action="uploadUrl" :on-preview="handlePreview" :on-remove="handleRemove" :file-list="fileList" :data="uploadData" :on-success="uploadSuccess">
                                <input type='hidden' name='taskId' v-model='detailId'></input>
                                <!--                                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>-->
                                <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传附件</el-button>
                            </el-upload>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="4">
            <uploading-attachments-button></uploading-attachments-button>
          </el-col> -->
                </el-row>

                <div v-if='form.auditResult===0'>
                    
                    <el-row>
                        <el-col :span="22">
                            <el-form-item label="审批情况：" prop="auditResult">
                                
                                <el-radio-group v-model="firstPassed" disabled v-if="form.secondAuditResult===0">
                                    <el-radio :label="1">通过</el-radio>
                                    <el-radio :label="0">不通过</el-radio>
                                </el-radio-group>
                                <el-radio-group v-model="form.auditResult" disabled v-else>
                                    <el-radio :label="1">通过</el-radio>
                                    <el-radio :label="0">不通过</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="审批理由：" prop="reason">
                                <el-input type="textarea" v-model="form.auditReason" style="width: 568px;" disabled></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12" :offset="12">
                            <el-form-item label="审批人：">
                                <el-input v-model="form.auditUser.name" disabled></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <br />
                <div v-if='form.secondAuditResult===0'>
                    <el-row>
                        <el-col :span="22">
                            <el-form-item label="二次审批情况：" prop="secondAuditResult">
                                <el-radio-group v-model="form.auditResult" disabled>
                                    <el-radio :label="1">通过</el-radio>
                                    <el-radio :label="0">不通过</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="审批理由：" prop="reason">
                                <el-input type="textarea" v-model="form.secondAuditReason" disabled style="width: 568px;"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12" :offset="12">
                            <el-form-item label="审批人：">
                                <el-input v-model="form.secondAuditUser.name" disabled></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="saveReport">保 存</el-button>
                <el-button type="primary" @click="submitReport">提 交</el-button>
                <el-button @click="dialogVisible = false">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import UploadingAttachments from "dialog/experimental-management/uploading-attachments-button";
  import {
    APPLY_TYPE_LIST,
    APPLY_STATUS_LIST
  } from 'service/constant';
    import {
        getApplyInfoByIdService,
        getPositionList,
        getTypeList,
        postDeleteAttach,
        getSampleStatusDrop
    } from "service/task";
    import {
        getLableFromList
    } from "utils/common";
    import {
        postSaveReportService,
        postTempSaveReportService
    } from "../../../../../service/task";


    export default {
        components: {
            "uploading-attachments-button": UploadingAttachments
        },
        data() {
            return {
                sampleStatusName:"",
                positionList: [],
                firstPassed: 1,
                isFullScreen: false,
                dialogVisible: this.show,
                activeName: "样品1",
                uploadUrl: `${process.env.API_URL}task/uploadAttach`,
                uploadResultUrl: `${process.env.API_URL}task/uploadResultAttach`,
                form: {
                    partNumber: "",
                    heatingNumber: "",
                    taskType: "",
                    partName: "",
                    totalPartNo: "",
                    applyUser: "",
                    partGraphNumber: "",
                    materialNo: "",
                    applyTime: "",
                    materialFurnanceNumber: "",
                    expectCompleteTime: "",
                    sampleStatus: "",
                    quantity: "",
                    remark: "",
                    part: {},
                    auditUser: {},
                    secondAuditUser: {}
                },
                editableTabs: [],
                tableData: [],
                recordData: [],
                fileList: [],
                uploadData: {
                    taskId: this.detailId
                }
            };
        },
        props: {
            show: {
                type: Boolean,
                default: false
            },
            detailId: {
                type: String
            }
        },
        mounted() {
            getPositionList().then(res => {
                this.positionList = res.data.result;
            });
        },
        watch: {
            show() {
                this.dialogVisible = this.show;
                this.uploadData.taskId = this.detailId;
                if (this.dialogVisible) {
                    getApplyInfoByIdService(this.detailId).then(res => {
                        // let taskTarget = res.data.result.taskTarget.split(",");
                        // this.form.taskNo = ;
                        // this.form.applyTime = res.data.result.applyTime;
                        // this.form.taskType = res.data.result.taskType;
                        // this.form.applyOrgName = res.data.result.applyUser.org.name;
                        // this.form.applyUser = res.data.result.applyUser.name;
                        // this.form.expectCompleteTime = res.data.result.expectCompleteTime;
                        // this.form.projectNo = res.data.result.projectNo;
                        // this.form.partNumber = res.data.result.partNumber;
                        // this.form.partGraphNumber = res.data.result.partGraphNumber;
                        // this.form.partName = res.data.result.partName;
                        // this.form.materialNo = res.data.result.materialNo;
                        // this.form.totalPartNo = res.data.result.totalPartNo;
                        // this.form.sampleStatusPhase = res.data.result.sampleStatusPhase;
                        // this.form.materialFurnanceNumber =
                        //   res.data.result.materialFurnanceNumber;
                        // this.form.heatingNumber = res.data.result.heatingNumber;
                        // this.form.sampleStatus = res.data.result.sampleStatus;
                        // this.form.quantity = res.data.result.quantity;
                        // this.form.batchNumber = res.data.result.batchNumber;
                        // this.form.provider = res.data.result.provider;
                        // this.form.remark = res.data.result.remark;
                        this.form = res.data.result;
                        getSampleStatusDrop().then(res2 => {
                            for(let i=0; i<res2.data.result.length;i++){
                                if(res.data.result.sampleStatus==res2.data.result[i].code){
                                this.sampleStatusName=res2.data.result[i].name;
                                }
                            }
                        });
                        if (!this.form.applyUser) {
                            this.form.applyUser = {};
                        }
                        // this.form.taskTarget = taskTarget;
                        this.form.part = res.data.result.part ? res.data.result.part : {};
                        this.tableData = [];
                        this.editableTabs = [];

                        if (!this.form.auditUser) {
                            this.form.auditUser = {};

                        }
                        if (!this.form.secondAuditUser) {
                            this.form.secondAuditUser = {};

                        }

                        let resultData = res.data.result.taskResultList;
                        for (let i = 0; i < res.data.result.quantity; i++) {
                            this.tableData.push([]);
                            this.editableTabs.push({
                                title: `样品${i + 1}`,
                                key: i
                            });
                        }
                        for (let i = 0; i < resultData.length; i++) {
                            // debugger;
                            this.tableData[resultData[i].sampleNo].push(resultData[i]);
                          if(resultData[i].taskField.partField.unit!=null){
                            resultData[i].standardInfoStr = resultData[i].taskField.fieldStandard + '(' + resultData[i].taskField.standardInfo + ')'+resultData[i].taskField.partField.unit;
                            }else{
                            resultData[i].standardInfoStr = resultData[i].taskField.fieldStandard + '(' + resultData[i].taskField.standardInfo + ')';
                            } 
                        }

                        let attachList = res.data.result.taskAttachList;
                        this.fileList = [];
                        attachList.forEach(e => {
                            let file = {
                                id: e.id,
                                name: e.fileName,
                                url: `${process.env.API_URL}task/downloadAttach?attachId=${e.id}`,
                                status: 'success',
                                uid: e.id,
                                percentage: 100,
                            };
                            this.fileList.push(file);
                        })
                    });
                }
            }
        },
        methods: {
             getType(t) {
        return getLableFromList(APPLY_TYPE_LIST, t);
      },
            remarkNeedWrite() {
              for(let i = 0; i < this.editableTabs.length; i++) {
                  for(let j = 0; j < this.tableData.length; j++) {
                      let tableDataList = this.tableData[i];
                      for(let m = 0; m < tableDataList.length; m++) {
                          let limit = tableDataList[m].taskField.partField.fieldStandard.numberLimit;
                          for(let k = 0; k < limit; k++) {
                              let data = tableDataList[m]['actData' +  (k+1)];
                              if(tableDataList[m]['actData' + (k+1)] == '' || tableDataList[m]['actData' + (k+1)] == null) {
                                  alert("实测数据不能为空");
                                  return true;
                              }
                          }
                          let standardInfo = tableDataList[m].taskField.standardInfo;
                          let deviceId = tableDataList[m].deviceId;
                           if(deviceId == null || deviceId == "") {
                                       alert("检测设备不能为空！")
                                       return true
                                   }
                          if(standardInfo == '符合/不符合') {
                              if(tableDataList[m].actData1 == "0" || tableDataList[m].actData2 == "0" || tableDataList[m].actData3 == "0"
                              || tableDataList[m].actData4 == "0" || tableDataList[m].actData5 == "0") {
                                   if(tableDataList[m].remark == null || tableDataList[m].remark == "") {
                                       alert("实测结果为不符合时需填写备注！")
                                       return true
                                   }
                              }
                          }
                      }
                  }
              }
            },

            getStatus(row, seq) {
                let limit = Number(row.taskField.partField.fieldStandard.numberLimit);
                if (seq <= limit) {
                    return false;
                } else {
                    return true;
                }
            },
            downloadResultAttach(id) {
                window.open(`${process.env.API_URL}task/downloadResultAttach?resultId=${id}`);
            },
            changeData(row, seq) {
                let decimalPoint = row.taskField.partField.decimalPoint;
                let operator = row.taskField.partField.operator;
                let limit = Number(row.taskField.partField.fieldStandard.numberLimit);
                if (!this.isNumber(row['actData' + seq])) {
                    row['actData' + seq] = null;
                    return;
                }
                for (let i = 1; i < seq; i++) {
                    if (!row['actData' + i]) {
                        row['actData' + seq] = null;
                        return;
                    }
                }
                if(operator !== 'choose') {
                      if(row['actData' + seq]) {
                         row['actData' + seq] = Number(row['actData' + seq]).toFixed(decimalPoint);
                      }
                  }
            },
            isNumber(val) {

                var regPos = /^\d+(\.\d+)?$/; //非负浮点数
                var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
                if (regPos.test(val) || regNeg.test(val)) {
                    return true;
                } else {
                    return false;
                }

            },
            rowResult(row) {
                for (let i = 1; i <= 5; i++) {
                    let col1 = row.taskField.col1,
                        col2 = row.taskField.col2;
                    let data = row['actData' + i];
                    if (data && data != '') {
                        if (row.taskField.partField.operator == "range") {
                            if (Number(data) < Number(col1) || Number(data) > Number(col2)) {
                                return 0;
                            }
                        } else if (row.taskField.partField.operator == "equal") {
                            if (Number(data) != Number(col1)) {
                                return 0;
                            }
                        } else if (row.taskField.partField.operator == "ge") {
                            if (Number(data) < Number(col1)) {
                                return 0;
                            }
                        } else if (row.taskField.partField.operator == "gr") {
                            if (Number(data)<= Number(col1)) {
                                return 0;
                            }
                        } else if (row.taskField.partField.operator == "le") {
                            if (Number(data)> Number(col1)) {
                                return 0;
                            }
                        } else if (row.taskField.partField.operator == "less") {
                            if (Number(data)>= Number(col1)) {
                                return 0;
                            }
                        } else {
                            if (parseInt(data) != 1) {
                                return 0;
                            }
                        }
                    }
                }
                return 1;
            },
            unqualifiedColColor(row, col) {
                for (let i = 1; i <= 5; i++) {
                    let col1 = row.taskField.col1,
                        col2 = row.taskField.col2;
                    let data = row['actData' + i];
                    if (data && data != '') {
                        if (row.taskField.partField.operator == "range") {
                            if ((Number(data) < Number(col1) || Number(data) > Number(col2)) &&  i == col){
                                return 0;
                            }
                        } else if (row.taskField.partField.operator == "equal") {
                            if ((Number(data) != Number(col1)) && i == col) {
                                return 0;
                            }
                        } else if (row.taskField.partField.operator == "ge") {
                            if ((Number(data) < Number(col1)) && i == col) {
                                return 0;
                            }
                        } else if (row.taskField.partField.operator == "gr") {
                            if ((Number(data)<= Number(col1)) && i == col) {
                                return 0;
                            }
                        } else if (row.taskField.partField.operator == "le") {
                            if ((Number(data)> Number(col1)) && i == col) {
                                return 0;
                            }
                        } else if (row.taskField.partField.operator == "less") {
                            if ((Number(data)>= Number(col1)) && i == col) {
                                return 0;
                            }
                        } else {
                            if ((parseInt(data) != 1 ) && i == col) {
                                return 0;
                            }
                        }
                    }
                }
                return 1;
            },
            submitReport() {
                if(this.remarkNeedWrite()) {
                    return;
                }
                 let confirm = this.$confirm('您确定提交吗?','提示',{
          // confirmButtonText: '确定',
          // cancelButtonText: '取消',
          type: 'warning'
        }).then(res => {
         postSaveReportService(this.form).then(res => {
                    if (res.data.success) {
                        this.$message({
                            message: res.data.message,
                            type: 'success',
                            duration: 1000
                        });
                        this.dialogVisible = false;
                        this.$emit('refreshAdd');
                    } else {
                        this.$alert(res.data.message, "提示", {
                            type: "error"
                        });
                    }
                });
      }).catch(res => {
         return
     });
            },
            saveReport() {
                if(this.remarkNeedWrite()) {
                    return;
                }
                postTempSaveReportService(this.form).then(res => {
                    if (res.data.success) {

                        this.$message({
                            message: res.data.message,
                            type: 'success',
                            duration: 1000
                        });
                    } else {
                        this.$alert(res.data.message, "提示", {
                            type: "error"
                        });
                    }
                });
            },
            getPosition(type) {
                return getLableFromList(this.positionList, type);
            },
            handleClose() {
                /* 关闭的时候更新状态值 */
                this.sampleStatusName="";
                  let confirm = this.$confirm('是否退出？', '提示', {
                  type: 'warning'
                }).then(confirmRes => {
                   this.isFullScreen = false;
                   this.dialogVisible = false;   
                }).catch(cancelRes => {
                })
            },
            handleClick(tab, event) {},
            submitUpload() {
                this.$refs.upload.submit();
            },
            uploadSuccess(res, file, fileList) {
                console.log(res)
                console.log(file);
                if (res.success) {
                    file.url = `${process.env.API_URL}task/downloadAttach?attachId=${res.result[0].id}`;
                    file.id = res.result[0].id;
                    file.percentage = 100;
                    console.log(fileList);
                    this.$message({
                        message: res.data.message,
                        type: 'success',
                        duration: 1000
                    });
                } else {
                    this.$alert(res.message, "提示", {
                        type: "success"
                    });
                }
            },
            successResultUpload(res, file, fileList) {
                if (res.success) {
                    let result = res.result;
                    for (let i = 0; i < this.form.taskResultList.length; i++) {
                        if (this.form.taskResultList[i].id == result.id) {
                            this.form.taskResultList[i].attachName = result.attachName;
                            this.form.taskResultList[i].attachUrl = result.attachUrl;
                            this.form.taskResultList[i].fileName = result.fileName;
                        }
                    }

                    this.$message({
                        message: res.data.message,
                        type: 'success',
                        duration: 1000
                    });
                } else {
                    this.$alert(res.message, "提示", {
                        type: "success"
                    });
                }
            },
            handleRemove(file, fileList) {
                if (file.id) {
                    postDeleteAttach(file.id).then(res => {
                        if (!res.data.success) {
                            this.$alert(res.data.message, "提示", {
                                type: "error"
                            });
                        }
                    })
                    console.log(file, fileList);
                }
            },
            handlePreview(file) {
                console.log(file);
            }
        }
    };

</script>

<style scoped>
    .uploadTitle {
        overflow: hidden;
        border-bottom: 1px solid #e2dede;
        margin-bottom: 10px;
    }

</style>
